package com.fuint.repository.common;

import com.fuint.repository.model.MtMerchant;
import io.swagger.models.auth.In;

import java.util.List;
import java.util.Objects;

public class Common {
    public static MtMerchant exchangeMerchant(Integer currentMerchant, List<MtMerchant> merchantList) {
        if(Objects.isNull(merchantList)) {
            return MtMerchant.builder().id(0).name("平台").build();
        }
        MtMerchant mtMerchant = merchantList.stream().filter(item -> item.getId().equals(currentMerchant)).findAny().orElse(null);
        if (Objects.nonNull(mtMerchant)) {
            return mtMerchant;
        }

        return MtMerchant.builder().id(0).name("平台").build();
    }
}
